﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IterationLife.Domains.Sports.Configs;
using IterationLife.Domains.Sports.Dtos.MTSports;
using IterationLife.Domains.Sports.Enums;
using IterationLife.Domains.Sports.Models;
using IterationLife.Domains.Sports.Repositories;
using IterationLife.Extensions.HttpRequest;
using Util.Domains;

namespace IterationLife.Domains.Sports.Services
{
    public class DataImportManager : DomainServiceBase, IDataImportManager
    {
        /// <summary>
        /// 构造
        /// </summary>
        /// <param name="sportUserRepository"></param>
        public DataImportManager(IZeppDataSerializable zeppDataSerializable, IMTDataSerializable mtDataSerializable, ISportUserRepository sportUserRepository, ISportTeamRepository sportTeamRepository, ISportEventRepository sportEventRepository)
        {
            MTDataSerializable = mtDataSerializable;
            SportUserRepository = sportUserRepository;
            SportTeamRepository = sportTeamRepository;
            SportEventRepository = sportEventRepository;
            ZeppDataSerializable = zeppDataSerializable;
        }

        protected ISportUserRepository SportUserRepository { get; set; }

        protected ISportTeamRepository SportTeamRepository { get; set; }

        protected ISportEventRepository SportEventRepository { get; set; }

        protected IMTDataSerializable MTDataSerializable { get; set; }
        protected IZeppDataSerializable ZeppDataSerializable { get; set; }
        #region 导入数据

        /// <summary>
        /// 导入数据
        /// </summary>
        public void Import(Guid userId)
        {
            var sportUser = SportUserRepository.Find(userId);
            if (sportUser == null)
                return;
            switch (sportUser.EquipmentType)
            {
                case EquipmentType.MT:
                    MTDataSerializable.Import(sportUser);
                    break;
                case EquipmentType.Zepp:
                    //ZeppDataSerializable.Import(sportUser);
                    break;
            }
        }

        #endregion
    }
}
